
import VueRouter from 'vue-router'
import About from '../pages/About'
import Home from '../pages/Home'
import Message from '../pages/Message'
import News from '../pages/News'
import Detail from '../pages/Detail'

export default new VueRouter({
    routers:[
        {
            path:"/about",
            component:About,
        },
        {
            path:"/home",
            component:Home,
            children:[
                {
                    path:"message",
                    component:Message,
                    children:[
                        {
                            name:"xiangqing",
                            path:"detail/:id/:title",
                            component:Detail,
                            // props传递参数，对象写法，会用props传递给Detail
                            // props:{
                            //     id:'001',
                            //     title:"zzz",
                            // },
                            // 布尔值写法，为真则会把params参数的所有值用props传递给Detail
                            // props:true,
                            // 函数写法，会用props传递给Detail
                            // props(route){
                            //     return {
                            //         id:route.params.id,
                            //         title:route.params.title,
                            //     }
                            // },
                            // 可以简写成
                            // 用结构赋值的写法
                            props({params}){
                                return {
                                    id:params.id,
                                    title:params.title,
                                }
                            },
                            // 可以简写成
                            // 结构赋值的连续写法
                            props({params:{id,title}}){
                                return {
                                    id,
                                    title,
                                }
                            },

                        }
                    ]
                },
                {
                    path:"news",
                    component:News
                },
            ]
        },
    ]
})
